cmake_minimum_required(VERSION 3.16.0)
project(dead-by-daylight-gui VERSION 1.0.0 LANGUAGES CXX)
find_package(Qt5 COMPONENTS Widgets REQUIRED)

set(CMAKE_PREFIX_PATH $ENV{QT_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON) # Meta-Object Compiler
set(CMAKE_AUTORCC ON) # Resource Compiler
set(CMAKE_AUTOUIC ON) # User Interface Compiler

file(GLOB_RECURSE GAME_SOURCE src/*.cpp)
file(GLOB_RECURSE GAME_HEADER src/*.h)
file(GLOB_RECURSE TS_FILES src/*.ts)
set(SRC_LIST
    ${GAME_HEADER}
    ${GAME_SOURCE}
    ${TS_FILES}
    )
set(PROJECT_SOURCES ${SRC_LIST})

# 这里如果不加WIN32，会导致编译的可执行文件运行时候会同时弹出一个命令行终端
# 这是Windows的特性，对于其它平台得去掉WIN32
add_executable(${CMAKE_PROJECT_NAME} WIN32 ${PROJECT_SOURCES})

# set /MT runtime flag
set_property(TARGET ${PROJECT_NAME} PROPERTY
             MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# cmake本身有四种编译模式：`Debug`, `Release`, `RelWithDebInfo`, `MinSizeRel`
# 此操作将`Debug`和`RelWithDebInfo`归类于QML的debug，即这两种模式下QML运行会保留debug信息
#target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

# 链接库到当前项目
# PRIVATE：项目私有内部链接，只有在开发Library对外公开时候才会使用PUBLIC
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE 
    Qt5::Widgets
)

#select startup project
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})